<!--
 * @Author: MrLee
 * @Date: 2024-08-24 08:55:14
 * @LastEditors: MrLee
 * @LastEditTime: 2024-08-25 13:10:36
 * @Description: 请填写简介
-->
<template>
  <custom-navbar title="投诉企业" :autoBack="true" leftIconColor="#303133" />
  <up-gap height="30rpx" />
  <view class="px-24rpx">
    <infocard :userInfoList="userInfoList" :rigthIco="false" />
  </view>
  <view class="shadow-[0px_0px_12px_0px_rgba(238,239,241,0.50)] fixed bottom-0 w-[100%] h-178rpx bg-#fff">
    <view
      class="w-[90%] h-82rpx mt-[24rpx] leading-[82rpx] mx-auto my-0 rounded-[42rpx] bg-#1f50f2 text-[30rpx] font-medium text-center text-white"
      @click="submitValue"
    >提交</view>
  </view>
</template>
  <script setup lang="ts">
  import infocard from "@/pages/components/infocard/index.vue";
  import {QyTs} from "@/api/user";
const userInfoList = reactive([
  {
    title: "企业名称",
    value: "",
    valueType: "input",
  },
  {
    title: "投诉类型",
    value: "请选择",
    label: "请选择",
    valueType: "select",
  },
  {
    title: "投诉内容",
    value: "请选择",
    valueType: "textarea",
    placeholder:'没有给您提供良好的体验，深感抱歉，请您详细描述遇到的问题，您希望如何解决，我们在了解情况后会尽快联系您，感谢您耐心等待',
  },
  {
    title: "上传图片",
    value: [],
    valueType: "file",
  }
]);
const submitValue = () => {
  console.log(userInfoList)
  let params = {
    company_name: userInfoList[0].value,
    type: userInfoList[1].value,
    content: userInfoList[2].value,
  }
  let arr = []
  userInfoList[3].value.map(v => {
    arr.push(v.url)
  })
  params.image = JSON.stringify(arr)
  console.log(params)
  QyTs(params).then(res => {
    console.log(res)
    if(res) {
      uni.showToast({
        title: '投诉成功',
        icon: 'none'
      })
    }else {
      uni.showToast({
        title: '投诉失败',
        icon: 'none'
      })
    }
  })
}
onMounted(() => {
  let config = JSON.parse(uni.getStorageSync('config')).configCli
  userInfoList[1].selectOptions = config.complaint_company_type$$投诉企业类型.map(v => {
    return {
      label: v.value,
      value: v.key
    }
  })
})
</script>
